package com.four.peoplemanage.gift.controller;

import com.four.peoplemanage.common.bean.ResponseData;
import com.four.peoplemanage.common.controller.BaseController;
import com.four.peoplemanage.gift.entity.Gift;
import com.four.peoplemanage.gift.service.GiftService;
import com.four.peoplemanage.overtime.entity.Overtime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/gift")
public class GiftController extends BaseController {
    @Autowired
    GiftService giftService;

    //添加礼品
    @PostMapping("/insert")
    public ResponseData<Boolean> insertGift(Gift gift){
        return returnBoolean(giftService.insert(gift));
    }

    //分页
    @GetMapping("/getAll")
    public ResponseData<Object>  getAll(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "giftname",required = false) String giftname,
            @RequestParam(value = "gift_claim_status",required = false) String gift_claim_status,
            @RequestParam(value = "status",required = false) String status


    ){
        return returnObject(giftService.getPageGift(pageNum, pageSize, giftname, gift_claim_status,status));
    }

    //分页
    @GetMapping("/getAll1")
    public ResponseData<Object>  getAll1(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "giftname",required = false) String giftname,
            @RequestParam(value = "gift_claim_status",required = false) String gift_claim_status,
            @RequestParam(value = "status",required = false) String status


    ){
        return returnObject(giftService.getPageGift1(pageNum, pageSize, giftname, gift_claim_status,status));
    }

    //更新状态
    @PutMapping("/updateS")
    public  ResponseData<Boolean> updateS(@RequestBody Gift gift){
        return returnBoolean(giftService.updateStatus(gift));
    }
}
